import java.awt.Component;

public class HiloZombie extends Thread {

	protected int startPosition;
	protected int endPosition;
	protected Component component;
	
	protected GUI padre;
	
	public HiloZombie( int startPosition, int endPosition, Component component, GUI padre ) {
		this.startPosition = startPosition;
		this.endPosition = endPosition;
		this.component = component;
		this.padre = padre;
	}
	
	public void run() {
		this.component.setLocation( startPosition, this.component.getLocation().y );
		int x = startPosition;
		while( x > this.endPosition ) {
			x = x - 1;
			this.component.setLocation( x, this.component.getLocation().y );
			try {
				Thread.sleep(50);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		if(x==0) {
			this.interrupted();
			padre.perdio();
		}
	}
	
	
	public int getPosition() {
		return this.component.getLocation().x;
	}
}
